package com.da.springtest.loop;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author chenlida
 * @date 2020/7/21 22:46
 * @description
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("AService")) {
            System.out.println(bean);
            // 这里会导致循环依赖报错
            //return new AService();
        }
        return bean;
    }
}
